<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
		<link rel="stylesheet" href="css/bootstrap.css">
		<style>
			
			.red {
				color: red;
				font-weight: 800;
			}
			
		</style>
		<!--0. 先引入vue.js-->
		<script src="../js/vue.js"></script>
	</head>
	<body>
		<div id="app">
			<div class="flex-column">
				<div class="d-flex" v-for="(item,i) in goodsList" :key="i">
					<img :src="item.img" width="200"></img>
					<div class="flex-column">
						<div>编号：{{item.id}}</div>
						<div>品名：{{item.name}}</div>
						<div>规格：{{item.spec}}</div>
						<div>单价：{{item.price}}</div>
						<div>数量：<span :class="item.count < 500 ? 'red' : ''">{{item.count}}</span> </div>
					</div>
				</div>
			</div>
		</div>
		<script src="../js/jquery-3.1.1.min.js"></script>
		<script type="text/javascript">
			new Vue({
				el: "#app",
				data: {
					goodsList: [],
				},
				mounted() {
					this.loadData();
				},
				methods: {
					loadData() {
						console.log("loadData")
						// 发送GET请求获取数据
						$.ajax({
							url: '../json/goodsList.json',
							type: 'get',
							dataType: 'json', // 指定数据类型为JSON
							success: data => {
								this.goodsList = data; // 将获取的数据存储到数组中	
								console.log(this.goodsList)
							}
						});
					}
				}
			})
		</script>
	</body>
</html>